<?php
/**
 * 主动请求企业微信接口封装
 * Created by PhpStorm.
 * User: sh01
 * Date: 2018/1/9
 * Time: 9:26
 */

namespace corpWeixin;

use corpWeixin\corpWeixinSdk\CWXTool;
use yii\base\Component;

/**
 * @property $CWXCallBack
 * @property $CWXDepartment
 * @property $CWXMedia
 * @property $CWXMessage
 * @property $CWXUser
 * @property $CWXTool
 */

class CWX extends Component
{

    public $config;
    private $cwxClasses=[
        'CWXCallBack' =>false,
        'CWXDepartment' =>false,
        'CWXMedia' =>false,
        'CWXMessage' =>false,
        'CWXUser' =>false,
        'CWXTool' =>false,
    ];
    public function init()
    {
        parent::init();
        $this->cwxClasses['CWXTool'] = CWXTool::create($this->config);
    }
    public function __get($className)
    {
        // TODO: Implement __get() method.
        if(!$this->cwxClasses[$className])
        {
            $className = '\\corpWeixin\\'.$className;
            $instance = new $className();
            $this->cwxClasses[$className] = $instance;
        }
        return $this->cwxClasses[$className];
    }
}